<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="UTF-8">
	<title>Aurora -锁屏</title>
    <link rel="stylesheet" th:href="@{'/plugins/css/layui.css'}">
    <link rel="stylesheet" th:href="@{'/css/lock.css'}">
    <link rel="stylesheet" th:href="@{'/plugins/font-awesome/css/font-awesome.min.css'}">
</head>
<body>
	<div class="get-lock-block">
        <div class="lock-head">
            <img th:src="@{${user.avatar}}" height="120">
        </div>
        <div class="input-div" id="App">

            <!--去除input密码自动填充-->
            <input type="text" placeholder="请输入登录密码" class="layui-input" onkeyup="this.value=this.value.replace(/[\u4e00-\u9fa5]/g,'')" v-model="pwd"
                      v-show="pwd.length==0" :data-val="inputTypeVal" ref="limao">

            <input placeholder="请输入登录密码" type="password" class="layui-input" v-show="pwd.length>0" ref="taize" name="lockPwd" autocomplete="off" v-model="pwd">
            <div class="el-input-group__append">

				<button type="button" onclick="unlock()" class="el-button">
	    			<i class="fa fa-lock" aria-hidden="true"></i>
	    		</button>

	    		<button type="button" id="logout" class="el-button">
	    			<i class="fa fa-sign-out" aria-hidden="true"></i>
	    		</button>
			</div>
        </div>
    </div>
    <!-- build:js -->
    <script th:src="@{'/js/jquery.min.js'}"></script>
    <script th:src="@{'/js/MD5.js'}"></script>
    <script th:src="@{'/js/lock/vue.js'}"></script>
    <script th:src="@{'/js/lock/index.js'}"></script>
    <script th:src="@{'/plugins/layui.js'}"></script>
    <script type="text/javascript">

		// 禁用F12，与右击
		document.onkeydown = function(e) {
			var e = window.event || arguments[0];
            if (e && e.keyCode == 13) {
                unlock();
            }
			if(e.keyCode == 123) {
				return false;
			} else if((e.ctrlKey) && (e.shiftKey) && (e.keyCode == 73)) {
				return false;
			} else if((e.shiftKey) && (e.keyCode == 121)) {
				return false;
			}
		};
		document.oncontextmenu = function() {
			return false;
		}

        //防止页面后退
        history.pushState(null, null, document.URL);
        window.addEventListener('popstate', function () {
            history.pushState(null, null, document.URL);
        });

        $("#logout").click(function () {
            window.location.href="/logout"
        })

        var layer = null;
        layui.use(['jquery', 'layer'], function () {
            layer = layui.layer;
        });

        /**
         * 解锁
         */
        function unlock() {
            var lockPwd = MD5($("[name='lockPwd']").val());
            $.ajax({
                url:"/user/unlock",
                data:{password:lockPwd},
                type:"POST",
                success:function(result){
                    if(result && result.code != 200){
                        layer.msg(result.msg+",默认密码：123456", {offset: 70, shift: 0});
                        return;
                    }else{
                        var url = result.msg.replace(",","#");
                        window.location.href = url;
                    }
                }
            });
        }
	</script>
    <!-- endbuild -->
</body>
</html>